import { NavigationGuardNext, RouteLocationNormalized, createRouter, createWebHashHistory } from 'vue-router'

import galgameHome from '../views/home/galgame/index.vue';
import baHomeHome from '../views/home/baHome/index.vue';
import baHomeAside from '../views/layout/asides/baIcoe/index.vue';

const router = createRouter({
    history: createWebHashHistory(),
    // history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'Home',
            component: () => import('../views/index.vue'),
            children: [
                {
                    path: '/galgame',
                    components: {
                        home: galgameHome,
                    }
                },
                {
                    path: '/baHome',
                    components: {
                        home: baHomeHome,
                        aside: baHomeAside,
                    },
                },
            ],
        },
    ]
});

router.beforeEach(
    (
        _to: RouteLocationNormalized,
        _from: RouteLocationNormalized,
        next: NavigationGuardNext
    ) => {
        if (_to.path == '/') {
            next('/galgame');
        }

        next();

    });

export default router
